package com.ultrapower.commons.utils;

import org.apache.commons.net.util.Base64;

/**项目名称：crankcall   
 * 类名称：Base6   
 * 类描述：Base6加密的工具类
 * 创建人：赵攀  
 * 创建时间：2016-12-13 下午5:04:43   
 * 修改人：   
 * 修改时间：   
 * 修改备注：   
 * @version    
 *
 */
public  class Base6 {
	/**
	 * 加密String明文输入,String密文输出
	 * 
	 * @param strPub 明文字符
	 * @return
	 */
	public static String encode(String strPub) {
		String strPri = "";
		//BASE64Encoder base64en = new BASE64Encoder();
		try { 
			//Base64.encodeBase64(bytes)
			strPri = new String(Base64.encodeBase64(strPub.getBytes("UTF-8")));
			//strPri = base64en.encode(strPub.getBytes("UTF-8"));
		} catch (Exception e) {
			e.printStackTrace();
		}
		return strPri;
	}

	/**
	 * 解密 以String密文输入,String明文输出
	 * 
	 * @param strMi
	 * @return
	 */
	public static String decode(String strPri) {
		
		 //return Base64.decodeBase64(strPri.getBytes("UTF-8"));
		//BASE64Decoder base64De = new BASE64Decoder();
		String strPub = "";
		try {
			byte[] bytePri = Base64.decodeBase64(strPri.getBytes("UTF-8"));
			strPub = new String(bytePri, "UTF-8");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return strPub;
	}
public static void main(String[] args) {
	System.out.println(decode("6YSC5beefOmEguWfjnzphILln47kuJzmlrnlsbEtWkxILTF8MTE0Ljk0NjY1fDMwLjIxNDgxfOmEguWfjuiKsea5luWMuuWfn+iQpemUgOS4reW/gw=="));
	System.out.println(decode("6YSC5beefOmEguWfjnzphILln47kuJzmlrnlsbEtWkxILTF8MTE0Ljk0NjY1fDMwLjIxNDgxfOmEguWfjuiKsea5luWMuuWfn+iQpemUgOS4reW/gw=="));
	System.out.println(decode("MTIzQHRlc3RAMTIzNDVAMC4wLjAuMEB0ZXN0="));
	System.out.println(encode("123@test@12345@0.0.0.0@test"));
	System.out.println(encode("123@testall@12345@0.0.0.0@testall"));//ZmY4MDgwODE2NDNjYTA4NTAxNjU2NWU1ZTljNzcwYjIxNTM1MDEyODkxMDc5QGh1aHVpQDhhOTk4YjI2NTE4MWI4YmUwMTUyM2VmMTYzMjQwMmQ1aDE1MzUwMTI5MDk3MjVAMTAuMzEuODEuMTE5QHZodWh1aTQ=
	System.out.println(decode("MTIzQHRlc3RhbGxAMTIzNDVAMC4wLjAuMEB0ZXN0YWxs"));
	System.out.println(decode("ZmY4MDgwODE2NDNjOWIyNTAxNjU2YjBlMDIwNjQ1MzYxNTM1MDk5NDA0ODA2QGh1aHVpQDhhOTk4YjI2NTE4MWI4YmUwMTUyM2VmMTYzMjQwMmQ1aDE1MzUwOTk0MTAwODBAMTAuMzEuODEuMTE5QHZodWh1aTQ="));
}
}
